<admintpl file="header" />
</head>
<body>
<div class="wrap js-check-wrap">
	<ul class="nav nav-tabs">
		<li><a href="{:U('Store/index')}">店铺列表</a></li>
		<li class="active"><a href="#" target="_self">编辑店铺</a></li>
	</ul>
	<form action="{:U('Store/revise')}" method="post" class="form-horizontal js-ajax-forms" enctype="multipart/form-data">
		<input type="hidden" name="store_id" value="{$store.store_id}">
		<div class="row-fluid">
			<div class="span9">
				<table class="table table-bordered">
					<tr>
						<th>用户名</th>
						<td>
							<input type="text" style="width:400px;" name="login_name" id="login_name" required value="{$store.login_name}" placeholder="请输入用户名"/>
							<span class="form-required">*商家登陆账号</span>
						</td>
					</tr>
					<tr>
						<th>密码</th>
						<td>
							<input type="text" style="width:400px;" name="password" id="password"  placeholder="请输入密码"/>
							<span class="form-required">*商家登陆密码（不修改不用填写密码）</span>
						</td>
					</tr>
					<tr>
						<th>手机号</th>
						<td>
							<input type="text" name="phone_mob" id="phone_mob" value="{$store.phone_mob}" required style="width: 400px" placeholder="请输入手机号">
							<span class="form-required">*商家手机号</span>
						</td>
					</tr>
					<tr>
						<th>邮箱</th>
						<td>
							<input type="text" name="email" id="email" value="{$store.email}"  style="width: 400px" placeholder="请输入邮箱">
							<span class="form-required">商家邮箱号</span>
						</td>
					</tr>
					<tr>
						<th>店铺名称</th>
						<td>
							<input type="text" name="store_name" required id="store_name" value="{$store.store_name}" style="width: 400px" placeholder="请输入店铺名称">
							<span class="form-required">*店铺名称</span>
						</td>
					</tr>
					<tr>
						<th>最低分佣比例</th>
						<td>
							<input type="text" name="min_sub" required id="min_sub" <if condition="$store['store_type'] eq 'personal'">readonly</if> value="{$store.min_sub_value}" placeholder="请输入最低分佣比例">
							<span class="form-required">*最低分佣比例  请输入小数！</span>
						</td>
					</tr>
					<tr>
						<th>销售总金额比较值</th>
						<td>
							<input type="number" name="sub_money"  id="sub_money" <if condition="$store['store_type'] eq 'personal'">readonly</if> value="{$store.sub_money}" style="width: 400px" placeholder="销售总金额比较值">
							<span class="form-required">单位：元 注：超过比较值金额 系统自动匹配最高分佣比例！</span>
						</td>
					</tr>
					<tr>
						<th>最高分佣比例</th>
						<td>
							<input type="text" name="max_sub"  id="max_sub"  <if condition="$store['store_type'] eq 'personal'">readonly</if>  value="{$store.max_sub_value}" style="width: 400px" placeholder="最高分佣比例">
							<span class="form-required">最高分佣比例  请输入小数！</span>
						</td>
					</tr>

					<if condition="$store['parent_id'] eq 0 && $store['store_type'] eq 'shops'">
						<tr>
							<th>选择结算方式</th>
							<td>
								<label class="radio"><input type="radio" name="settlement_method" value="clique" <if condition="$store.settlement_method eq 'clique'">checked</if>>集团结算</label>
								<label class="radio"><input type="radio" name="settlement_method" value="shop" <if condition="$store.settlement_method eq 'shop'">checked</if>>店铺结算</label>
							</td>
						</tr>
					</if>

					<tr>
						<th>是否按照地区选择用户</th>
						<td>
							<label class="radio"><input type="radio" name="is_region_choice" value="1" <if condition="$store.is_region_choice eq 1">checked</if>>是</label>
							<label class="radio"><input type="radio" name="is_region_choice" value="0" <if condition="$store.is_region_choice eq 0">checked</if>>否</label>
						</td>
					</tr>
					<tr>
						<th>是否为总店铺</th>
						<td>
							<label class="radio"><input type="radio" name="is_main" value="1" <if condition="$store.parent_id eq 0">checked</if>>是</label>
							<label class="radio"><input type="radio" name="is_main" value="0" <if condition="$store.parent_id neq 0">checked</if>>否</label>
						</td>
					</tr>

					<tr>
						<th>是否开启店铺归属码</th>
						<td>
							<label class="radio"><input type="radio" name="attribution_switch" value="1" <if condition="$store.attribution_switch eq 1">checked</if>>是</label>
							<label class="radio"><input type="radio" name="attribution_switch" value="0" <if condition="$store.attribution_switch eq 0">checked</if>>否</label>
						</td>
					</tr>
					<tr>
						<th>店铺归属码</th>
						<td>
							<input type="text" name="attribution_code"  id="attribution_code" value="{$store.attribution_code}" style="width: 400px" placeholder="请填写店铺归属码">
							<span class="form-required">请确认上方按钮是否开启，不开启填写无效！</span>
						</td>
					</tr>

					<tr <if condition="$store.parent_id eq 0">style="display: none"</if> id="parent">
						<th>选择总店铺</th>
						<td>
							<select style="min-width: 190px;" name="parent_id">
								<option value="0">请选择店铺</option>
								<volist name="storeList" id="re">
									<option value="{$re.store_id}" <if condition="$re['store_id'] eq $store['parent_id']">selected</if>>{$re.store_name}</option>
								</volist>
							</select>
						</td>
					</tr>
					<tr>
						<th>已填地址</th>
						<td>
							<input id="lc-input-region_name1" class="form-control" type="text" name="region_name1" value="{$store.region_name}" style="width: auto" disabled="ture"/>
						</td>
					</tr>
					<tr>
						<th>地区</th>
						<td>
							<select style="min-width: 190px;" name="region1" id="lc-select1-region">
								<option value="0">请选择</option>
								<volist name="region1" id="re">
									<option value="{$re.region_id}">{$re.region_name}</option>
								</volist>
							</select>
							<select class="p-no-margin form-control" name="region2" value="0" id="lc-select2-region" style="display: none; width: auto;">
								<option value="0">请选择</option>
							</select>
							<input style="display: none;" id="lc-input-region_name" name="region_name">
						</td>
					</tr>
					<tr>
						<th>地址</th>
						<td>
							<input type="text" name="address"  id="address" value="{$store.address}"  style="width: 400px" placeholder="请输入地址信息">
							<span class="form-required">*详细地址</span>
						</td>
					</tr>
					<tr>
						<th>小程序抬头名称</th>
						<td>
							<input type="text" name="logo_name"  id="logo_name" value="{$store.logo_name}"  style="width: 400px" placeholder="请输入小程序抬头名称">
							<span class="form-required">*小程序抬头名称</span>
						</td>
					</tr>
				</table>
			</div>
			<div class="span3">
				<table class="table table-bordered">
					<tr>
						<th><b>logo</b></th>
					</tr>
					<tr>
						<td>
							<div style="text-align: center;">
								<input type="hidden" name="store_logo" id="thumb" value="{$store.store_logo|default=''}">
								<a href="javascript:upload_one_image('图片上传','#thumb');">
									<if condition="empty($store['store_logo'])">
										<img src="__TMPL__Public/assets/images/default-thumbnail.png" id="thumb-preview" width="135" style="cursor: hand"/>
										<else />
										<img src="../{$store['store_logo']}" id="thumb-preview" width="135" style="cursor: hand"/>
									</if>
								</a>
								<input type="button" class="btn btn-small" onclick="$('#thumb-preview').attr('src','__TMPL__Public/assets/images/default-thumbnail.png');$('#thumb').val('');return false;" value="取消图片">

							</div>
						</td>
					</tr>
					<tr>
						<th>状态</th>
					</tr>
					<tr>
						<td>
							<select class="p-no-margin form-control" value="0" id="lc-select-state" name="state">
								<option value="0" <if condition="$store.state eq 0">selected</if>>未选择</option>
								<option value="1" <if condition="$store.state eq 1">selected</if>>启用</option>
								<option value="2" <if condition="$store.state eq 2">selected</if>>关闭</option>
							</select>
						</td>
					</tr>
				</table>
			</div>
		</div>
		<div class="form-actions">
			<button class="btn btn-primary js-ajax-submit" type="submit">提交</button>
			<a class="btn" href="{:U('Store/index')}">返回</a>
		</div>
	</form>
</div>
<script type="text/javascript" src="__PUBLIC__/js/common.js"></script>

<script>

    $("input[name=is_main]").change(function(){
        var is_show_gift = $('input[name=is_main]:checked').val();
        if(is_show_gift == 0){
            $("#parent").show();
        }else{
            $("#parent").hide();
        }
    })


    var region = '';
    $("#lc-select1-region").on('change',function () {
        if($(this).val()){
            $.ajax({
                type:"post",
                url:"{:U('Store/getRegion')}",
                async:true,
                data:{'parent_id':$(this).val()},
                dataType:"json",
                success:function(result) {
                    if (result.code == 10000) {
                        var shtml = '';
                        for(var i in result.data){
                            shtml += '<option value="'+result.data[i].region_id+'">'+result.data[i].region_name+'</option>'
                        }
                        var start = '<option value="0" selected>请选择</option>'
                        $("#lc-select2-region").html(start+shtml)
                        $("#lc-select2-region").css('display','');
                        $("#lc-select3-region").css('display','none');
                        change_region();
                    }
                }
            });
        }
    })
    $("#lc-select2-region").on('change',function () {
        if($(this).val()){
            $.ajax({
                type:"post",
                url:"{:U('Store/getRegion')}",
                async:true,
                data:{'parent_id':$(this).val()},
                dataType:"json",
                success:function(result) {
                    if (result.code == 10000) {
                        var shtml = '';
                        for(var i in result.data){
                            shtml += '<option value="'+result.data[i].region_id+'">'+result.data[i].region_name+'</option>'
                        }
                        var start = '<option value="0" selected>请选择</option>'
                        $("#lc-select3-region").html(start+shtml)
                        $("#lc-select3-region").css('display','');
                        change_region();
                    }
                }
            });
        }
    })
    $("#lc-select3-region").on('change',function () {
        change_region();
    });
    function change_region() {
        region = ''
        console.log($("#lc-select3-region").val())
        if($("#lc-select1-region").val() != 0){
            region += $("#lc-select1-region option:selected").text() + ' ';
        }
        if($("#lc-select2-region").val() != 0){
            region += $("#lc-select2-region option:selected").text() + ' ';
        }
        if($("#lc-select3-region").val() != 0){
            region += $("#lc-select3-region option:selected").text() + ' ';
        }
        $("#lc-input-region_name").val(region);
        console.log($("#lc-input-region_name").val())
    }
    $("#lc-btn-return").click(function () {
        location.href = "{:U('Store/index')}";
    })
    $("button.revise-region").click(function () {
        $("#lc-div-input").css('display','none');
        $("#lc-div-select").css('display','');
        $("#lc-input-region_name").removeAttr('disabled');
    })
</script>
</body>

</html>
